using System;
using UnityEngine;

namespace Gameplay.PVE
{
    public class AStarNodeInfo : MonoBehaviour
    {
        public int x;
        public int y;
        public int id;
        public bool isBlock;
        public float maxDistance;

        public GameObject plane;
        public GameObject plane2;

        private Material blockMat;
        private Material normalMat;
        
        public void Init(int x, int y)
        {
            id = x * 10000 + y;
            this.x = x;
            this.y = y;
            //plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
            //plane.transform.SetParent(this.gameObject.transform);
            plane.transform.localPosition = Vector3.zero;
            plane.transform.localScale = new Vector3(AStarMgr.gridSize.x / 10 * 0.95f, 0, AStarMgr.gridSize.y / 10 * 0.95f);
            
            //plane2 = GameObject.CreatePrimitive(PrimitiveType.Plane);
            //plane2.transform.SetParent(this.gameObject.transform);
            plane2.transform.localPosition = Vector3.zero;
            plane2.transform.localScale = new Vector3(AStarMgr.gridSize.x / 10 * 0.95f, 0, AStarMgr.gridSize.y / 10 * 0.95f);
            /*sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.transform.SetParent(this.gameObject.transform);
            sphere.transform.localPosition = Vector3.zero;
            sphere.transform.localScale = new Vector3(AStarMgr.gridSize.x * 0.9f, 0, AStarMgr.gridSize.y * 0.9f);*/
        }
        public void UpdateBlock(float maxDistance,bool isBlock)
        {
            this.isBlock = isBlock;
            this.maxDistance = maxDistance;
            plane.SetActive(!isBlock);
            plane2.SetActive(isBlock);
        }
#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            UnityEditor.Handles.Label(transform.position,string.Format("({0},{1})",x,y));
        }
#endif
    }
}